package com.huawei.appgallery.packagemanager.impl.uninstall.process;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.huawei.appgallery.packagemanager.impl.base.PackageBaseActivity;
import com.huawei.secure.android.common.intent.SafeIntent;
import com.huawei.updatesdk.service.otaupdate.UpdateStatusCode.DialogButton;
import o.cnu;
import o.cop;
import o.cov;
import o.cpu;

public class PackageUninstallerActivity extends PackageBaseActivity {
    private String ˋ = "";
    private boolean ˎ = false;
    private String ˏ = "";
    private long ॱ;

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Intent intent = getIntent();
        if (intent == null) {
            finish();
            cnu.ˏ.ˊ("PackageUninstallerActivity", "error intent");
            return;
        }
        SafeIntent safeIntent = new SafeIntent(intent);
        this.ˋ = safeIntent.getStringExtra("uninstall_packagename");
        if (this.ˋ != null) {
            cov.ˏ(getApplicationContext()).removeMessages(this.ˋ.hashCode());
        }
        this.ˎ = safeIntent.getBooleanExtra("uninstall_for_all_user", false);
        this.ॱ = safeIntent.getLongExtra("uninstall_taskId", 0);
        this.ˏ = "uninstall:" + this.ˋ;
        intent = new Intent("android.intent.action.DELETE", Uri.parse("package:" + this.ˋ));
        intent.putExtra("android.intent.extra.RETURN_RESULT", true);
        intent.putExtra("android.intent.extra.UNINSTALL_ALL_USERS", this.ˎ);
        cnu.ˏ.ˋ("PackageUninstallerActivity", "onCreate packageName:" + this.ˋ);
        try {
            startActivityForResult(intent, DialogButton.CONFIRM);
        } catch (ActivityNotFoundException e) {
            cpu.ॱ(getApplicationContext(), this.ˋ, 1000001, this.ॱ, 5);
        }
        if (cop.ˎ != null) {
            cop.ˎ.ˎ(this.ˏ, this);
        }
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        int i3 = -5;
        super.onActivityResult(i, i2, intent);
        cnu.ˏ.ˎ("PackageUninstallerActivity", " onActivityResult requestCode:" + i + ",resultCode:" + i2);
        if (DialogButton.CONFIRM == i) {
            this.ˊ = true;
            if (i2 == 0) {
                ˊ();
            } else {
                if (intent != null) {
                    i3 = intent.getIntExtra("android.intent.extra.INSTALL_RESULT", -5);
                }
                cnu.ˏ.ˋ("PackageUninstallerActivity", " package uninstall system callback:packageName:" + this.ˋ + ",returnCode:" + i3);
                cpu.ॱ(getApplicationContext(), this.ˋ, i3, this.ॱ, 4);
            }
        }
        finish();
    }

    public void ˊ() {
        super.ˊ();
        cnu.ˏ.ˋ("PackageUninstallerActivity", " package uninstall system callback:packageName:" + this.ˋ + " user cancel");
        cpu.ॱ(getApplicationContext(), this.ˋ, 1000001, this.ॱ, 4);
    }

    public void onDestroy() {
        super.onDestroy();
        finishActivity(DialogButton.CONFIRM);
        if (cop.ˎ != null) {
            cop.ˎ.ˏ(this.ˏ, this);
        }
        cnu.ˏ.ˎ("PackageUninstallerActivity", "removeTaskId:" + this.ˏ);
    }
}
